package object_oriented;

public class Sorter {
    public void traversal( int[] array ){            //遍历数组
        if(array == null){
            System.out.println( "该数组并未初始化" );
        }else if(array.length == 0 ){
            System.out.println( "该数组长度为0" );
        }else{
            for (int i = 0; i < array.length - 1; i++) {
                System.out.print( array [i] + ",");
            }
            System.out.println( array[array.length-1]);
        }
    }

    public void sort( int[] array ) {    //一维数组排序
        int temp = 0 ;

        for (int i = 0; i < array.length - 1; i++) {
            for (int j = 0; j < array.length - i - 1; j++) {
                if(array[j] <= array[j+1]){
                    temp = array[j+1] ;
                    array[j+1] = array[j] ;
                    array[j] = temp ;
                 }
            }
        }
    }

}
